﻿using System;
using fastCSharp;

namespace diantou.web.contest
{
    /// <summary>
    /// 用户在问题下的提交记录
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPool = true, IsReferer = false)]
    partial class problemSubmitList : problemView<problemSubmitList>
    {
        /// <summary>
        /// 用户提交问题列表
        /// </summary>
        private submitList.problemJudge[] problemArray = new submitList.problemJudge[] { new submitList.problemJudge() };
        /// <summary>
        /// 用户提交问题列表
        /// </summary>
        private submitList.problemJudge[] problems;
        /// <summary>
        /// 用户信息
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private diantou.dataAccess.user user;
        /// <summary>
        /// 用户的提交记录
        /// </summary>
        /// <param name="problemId"></param>
        /// <param name="userId"></param>
        /// <returns>是否成功</returns>
        private bool loadView(int problemId, int userId)
        {
            if (base.loadView(problemId))
            {
                if (userId == 0 || (currentUser != null && currentUser.Id == userId)) user = currentUser;
                else user = diantou.dataAccess.clientCache.User[userId];
                if (user != null)
                {
                    diantou.dataAccess.problem problem = diantou.dataAccess.clientCache.Problem[problemId];
                    if (problem != null)
                    {
                        diantou.dataAccess.contestJudge.problemJudge problemJudge = diantou.dataAccess.tcpCall.contestJudge.getUserProblem(user.Id, problemId);
                        if (problemJudge == null) problems = nullValue<submitList.problemJudge>.Array;
                        else (problems = problemArray)[0].Set(problemJudge, user.Id, currentUser);
                        return true;
                    }
                }
                AjaxResponse(webConfig.NotFound404);
            }
            return false;
        }
        /// <summary>
        /// 清除数据
        /// </summary>
        protected override void clear()
        {
            base.clear();
            problemArray[0].Clear();
        }
    }
}
